    /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Task2;

import java.io.Serializable;
import java.rmi.RemoteException;
import java.util.HashMap;

/**
 *
 * @author Patrick Füssinger
 * Exercise 2 bis 21.Nov.2011
 * ITB5_2
 * 
 * Implementation der ATM
 */
public class ATMImpl implements iATM, Serializable{

    private HashMap<Integer, Account> m_oAccountMap = new HashMap<Integer, Account>();
    
    public ATMImpl(){
        
        //Creat TestAccounts
        Account oAccount1 = new Account(0);
        Account oAccount2 = new Account(100);
        Account oAccount3 = new Account(500);
        m_oAccountMap.put(oAccount1.getAccountNr(), oAccount1);
        m_oAccountMap.put(oAccount2.getAccountNr(), oAccount2);
        m_oAccountMap.put(oAccount3.getAccountNr(), oAccount3);
        
    }
    
    /*
     * Einzahlen auf das Konto
     */
    public void deposit(int iAccount, float iAmount) throws RemoteException {
        m_oAccountMap.get(iAccount).setBalance(getBalance(iAccount) + iAmount);
    }

    /*
     * Abheben vom Konto
     */
    public void withdraw(int iAccount, float iAmount) throws RemoteException {
        m_oAccountMap.get(iAccount).setBalance(getBalance(iAccount) - iAmount);
    }

    /*
     * Kontostand abfragen
     */
    public float getBalance(int iAccount) throws RemoteException {
        return m_oAccountMap.get(iAccount).getBalance();
    }

    
}
